#ifndef __JIENING_PLURAL_HEAD__
#define __JIENING_PLURAL_HEAD__

#include <vector>
#include <iostream>
#include <sstream>
using namespace std;

class jieningPlural
{
public:
	static const double ZEROVAL = 1.0e-9;
	static const double PI=3.1416;

	jieningPlural(){this->m_real=0.0; this->m_imag=0.0;}
	jieningPlural(double rl, double im){this->m_real=rl; this->m_imag=im;}
	//拷贝构造函数
	jieningPlural(const jieningPlural& obj){this->m_real = obj.m_real; this->m_imag=obj.m_imag;}

	//赋值符重载
	jieningPlural& operator =(const jieningPlural& obj);
	
	//加号重载
	jieningPlural operator +(const jieningPlural& obj);
	jieningPlural operator +(double val);
	jieningPlural& operator +=(const jieningPlural& obj);
	jieningPlural& operator +=(double val);

	//减号重载
	jieningPlural operator -(const jieningPlural& obj);
	jieningPlural operator -(double val);
	jieningPlural& operator -=(const jieningPlural& obj);
	jieningPlural& operator -=(double val);

	//乘号重载
	jieningPlural operator *(const jieningPlural& obj);
	jieningPlural operator *(double val);
	jieningPlural& operator *=(const jieningPlural& obj);
	jieningPlural& operator *=(double val);

	//除号重载
	jieningPlural operator /(const jieningPlural& obj);
	jieningPlural operator /(double val);
	jieningPlural& operator /=(const jieningPlural& obj);
	jieningPlural& operator /=(double val);


	//比较符号重载
	bool operator ==(const jieningPlural& obj) const;
	bool operator <(const jieningPlural& obj) const;
	bool operator <=(const jieningPlural& obj) const;
	bool operator >(const jieningPlural& obj) const;
	bool operator >=(const jieningPlural& obj) const;

	//取得复数模
	double getModulus() const;

	//复数幅角(弧度)
	double getArg() const;

	//取得共轭
	jieningPlural getAdjoint(){return jieningPlural(this->m_real, -(this->m_imag));}

	string toString() const;
	string toStringMG() const;
	string toStringMGd() const;

	double m_real;
	double m_imag;

};

std::ostream& operator<<(std::ostream& out, jieningPlural& thepl);
std::ostream& operator<<(std::ostream& out, const jieningPlural& thepl);
#endif
